﻿using System;
using Jayden.Dll.Core.Extensions;
using Jayden.Dll.Web.Enums;
using Jayden.Dll.Web.HtmlControls.Descriptions;
using Jayden.Dll.Web.HtmlControls.Generics;
using Jayden.Dll.Web.HtmlControls.Interfaces;

namespace Jayden.Dll.Web.HtmlControls
{

	public class Command : HtmlElement, WithLabel, WithDisabled, WithChecked
	{
		public Command() : base(CommandDescription.Instance) { }

		public HtmlCommandType Type { get { return (HtmlCommandType)Enum.Parse(typeof(HtmlCommandType), GetAttribute("type", false, false, "command").CamelCase(), true); } set { this["type"] = (value == HtmlCommandType.Command) ? null : value.ToString().UnCamelCase(); } }
		public string Label { get { return this["label"]; } set { this["label"] = value; } }
		public string Icon { get { return this["icon"]; } set { this["icon"] = value; } }
		public bool Disabled { get { return GetAttributeBool("disabled"); } set { SetAttribute("disabled", value); } }
		public bool Enabled { get { return !Disabled; } set { Disabled = !value; } }

		public bool Checked { get { return GetAttributeBool("checked"); } set { SetAttribute("checked", value); } }
		public string RadioGroup { get { return this["radiogroup"]; } set { this["radiogroup"] = value; } }

	}
	public class CommandDescription : HtmlElementDescription
	{
		public static readonly CommandDescription Instance = new CommandDescription();
		private CommandDescription() : base("command", HtmlVersion.Html5, false, false) { }
		public override Type ControlType { get { return typeof(Command); } }
		public override bool IsPhrasingElement { get { return true; } }
		public override bool IsMetaDataElement { get { return true; } }
		public override string Description { get { return "multipurpose element for representing commands."; } }
	}
}
